<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <form>
        <input type="text" name="username" placeholder="请输入用户名">
        <input type="password" name="password" placeholder="请输入密码">
        <input type="button" value="提交">
        <h1></h1>
    </form>

    <script>
        let btn = document.getElementsByTagName('input')[2]
        btn.onclick = function () {
            let xhr = new XMLHttpRequest()
            xhr.open('get', '/user?username=LiuFan&password=040670')
            xhr.send(null)
            xhr.onreadystatechange = function () {
                if (xhr.status == 200 && xhr.readyState == 4) {
                    document.querySelector('h1').innerHTML = xhr.responseText
                }
            }
        }
    </script>
</body>

</html>